/**
 * Copyright (c) 2018-2099, Joffee.
 * <p>
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.gnu.org/licenses/lgpl.html
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sailmi.eimp.resourceEventType.controller;


import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import com.sailmi.common.mybatis.support.Condition;
import com.sailmi.common.mybatis.support.Query;
import com.sailmi.common.tool.api.R;
import com.sailmi.common.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sailmi.eimp.resourceEventType.entity.ResourceEventtype;
import com.sailmi.eimp.resourceEventType.vo.ResourceEventtypeVO;
import com.sailmi.eimp.resourceEventType.wrapper.ResourceEventtypeWrapper;
import com.sailmi.eimp.resourceEventType.service.IResourceEventtypeService;
import com.sailmi.common.controller.BaseController;

/**
 *  控制器
 *
 * @author Joffee
 * @since 2025-03-25
 */
@RestController
@RequestMapping("/resourceeventtype")
@Tag(name = "", description = "接口")
public class ResourceEventtypeController extends BaseController {
    @Resource
	private IResourceEventtypeService resourceEventtypeService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@Operation(summary = "详情", description = "传入resourceEventtype")
	public R<ResourceEventtypeVO> detail(@ModelAttribute ResourceEventtype resourceEventtype) {
		ResourceEventtype detail = resourceEventtypeService.getOne(Condition.getQueryWrapper(resourceEventtype));
		return R.data(ResourceEventtypeWrapper.build().entityVO(detail));
	}

	/**
	 * 分页 
	 */
	@GetMapping("/list")
	@Operation(summary = "分页", description = "传入resourceEventtype")
	public R<IPage<ResourceEventtypeVO>> list(@ModelAttribute ResourceEventtype resourceEventtype,@ModelAttribute Query query) {
		IPage<ResourceEventtype> pages = resourceEventtypeService.page(Condition.getPage(query), Condition.getQueryWrapper(resourceEventtype));
		return R.data(ResourceEventtypeWrapper.build().pageVO(pages));
	}


	/**
	 * 自定义分页 
	 */
	@GetMapping("/page")
	@Operation(summary = "分页", description = "传入resourceEventtype")
	public R<IPage<ResourceEventtypeVO>> page(@ModelAttribute ResourceEventtypeVO resourceEventtype,@ModelAttribute Query query) {
		IPage<ResourceEventtypeVO> pages = resourceEventtypeService.selectResourceEventtypePage(Condition.getPage(query), resourceEventtype);
		return R.data(pages);
	}

	/**
	 * 新增 
	 */
	@PostMapping("/save")
	@Operation(summary = "新增", description = "传入resourceEventtype")
	public R save(@Valid @RequestBody ResourceEventtype resourceEventtype) {
		return R.status(resourceEventtypeService.save(resourceEventtype));
	}

	/**
	 * 修改 
	 */
	@PostMapping("/update")
	@Operation(summary = "修改", description = "传入resourceEventtype")
	public R update(@Valid @RequestBody ResourceEventtype resourceEventtype) {
		return R.status(resourceEventtypeService.updateById(resourceEventtype));
	}

	/**
	 * 新增或修改 
	 */
	@PostMapping("/submit")
	@Operation(summary = "新增或修改", description = "传入resourceEventtype")
	public R submit(@Valid @RequestBody ResourceEventtype resourceEventtype) {
		return R.status(resourceEventtypeService.saveOrUpdate(resourceEventtype));
	}


	/**
	 * 删除 
	 */
	@PostMapping("/remove")
	@Operation(summary = "逻辑删除", description = "传入ids")
	public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
		return R.status(resourceEventtypeService.deleteLogic(Func.toLongList(ids)));
	}


}
